# $Id: PKGBUILD 180686 2013-03-25 19:15:37Z bpiotrowski $
# Maintainer: kevin <kevin@archlinux.org>
# Contributor: Eric Johnson <eric@coding-zone.com>

pkgname=perl-dbd-mysql
_realname=DBD-mysql
pkgver=4.022
pkgrel=3
pkgdesc="Perl/CPAN DBD::mysql module for interacting with MySQL via DBD"
arch=('i686' 'x86_64')
license=('GPL' 'PerlArtistic')
url="http://search.cpan.org/dist/${_realname}/"
depends=('libmariadbclient' 'perl-dbi')
makedepends=('mariadb')
options=('!emptydirs')
source=(http://search.cpan.org/CPAN/authors/id/C/CA/CAPTTOFU/${_realname}-${pkgver}.tar.gz)
md5sums=('20fb571245e3b9ac275b8329025c4bf6')

build() {
  cd "${srcdir}/${_realname}-${pkgver}"

  # install module in vendor directories.
  perl Makefile.PL INSTALLDIRS=vendor --testsocket=/tmp/socket.mysql
  make
}

check() {
  cd "${srcdir}/${_realname}-${pkgver}"
  mkdir -p /tmp/mysql_test
  mysql_install_db \
     --basedir=/usr \
     --datadir=/tmp/mysql_test
  mysqld -P 17999 \
     --socket=/tmp/socket.mysql \
     --datadir=/tmp/mysql_test &
  sleep 10
  DAEMON_PORT=$!
  make test || true
  kill -9 $DAEMON_PORT
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"
  make install DESTDIR="${pkgdir}"
}
